﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Reflection;
using Common.Entity;

namespace Common.Facade.PageBase
{
    public abstract class EditMVPPage : Page
    {
        protected Presenter.EditPresenter Presenter;
        /// <summary>
        /// 注册Presenter
        /// </summary>
        protected abstract void RegistrPresenter();

        protected override void OnInit(EventArgs e)
        {
            RegistrPresenter();
            base.OnInit(e);
        }

        protected void EventHandlerInit(EventHandler handler, EventHandler method)
        {
            handler += new EventHandler(method);
        }
        /// <summary>
        /// 注册事件
        /// </summary>
        protected abstract void RegistrEvent();

        protected void Page_Load(object sender, EventArgs e)
        {
            RegistrEvent();
            Presenter.Initialization();//在Presenter中完成
        }

        public virtual void Save()
        {
            if (Presenter.ModelKey != null)
            {
                IModelBase model = Presenter.GetModelByClient();
                model.SetModelKey(Presenter.ModelKey);
                Presenter.BLLClass.Update(model);
            }
        }
    }
}
